package com.rlz.base.base

import com.rlz.libs.log.P
import io.reactivex.Observer
import io.reactivex.disposables.Disposable

/**
 * Created by RLZ
 * on 2021/3/8
 *
 */
abstract class BaseObserver<T> : Observer<T> {


    override fun onSubscribe(d: Disposable) {

    }

    override fun onNext(t: T) {
        onSuccess(t)
    }

    override fun onError(e: Throwable) {
        e.stackTrace.forEach {
            P.e("Error", it.toString())
        }
        Resource.error<T>(e)
    }

    override fun onComplete() {
    }

    abstract fun onSuccess(t: T)
}